import { ref, computed, reactive } from 'vue'
import { defineStore } from 'pinia'
import {leave_list,leave_delete,leave_check,leave_add,leave_reset,health_list,health_delete,health_remind,leave_review_list,leave_review_check} from '../../utils/api'
export const useStudentsleaveStore = defineStore('Studentsleave', () => {
  // 学生请假数据
  var leavelist = ref({list:[]})
  var leavelistcheck = ref({})
  // 学生审核数据
  var checkslist = ref({list:[]})
  var checksreviewlist = ref({})
  // var leavelist = reactive([])
  // 健康中心数据
  var healthlist = ref({list:[]})
  // let data = ref([])
  // 获取学生请假列表
  function leave_List() {
    leave_list().then((res)=>{
        // console.log(res.data.list);
        leavelist.value.list = res.data.list;
        // console.log(leavelist.list);
    })
  }
  // 撤销学生请假列表
  function leaveList_delete(row){
    // console.log(leavelist._rawValue);
    leave_delete({id:row}).then((res)=>{
      leavelist.value.list = res.data.list;
      // console.log(leavelist.value);
      // console.log(res.data.list);
    })
  }
  // 查看学生请假列表
  function leaveList_check(row){
    // console.log(leavelist._rawValue);
    leave_check({id:row}).then((res)=>{
      // console.log(res.data.list);
      leavelistcheck.value.list = res.data.list;
      console.log(leavelistcheck.value.list);
      // console.log(res.data.obj);
    })
  }
  // 新增学生请假列表
  function leaveList_add(row){
    leave_add(row).then((res)=>{
     if(res.status == 200){
      leavelist.value = res.data.list
     }
    })
  }
  // 获取请假审核列表
  function leaveReview_List() {
    leave_review_list().then((res)=>{
        // console.log(res.data.list);
        checkslist.value.list = res.data.list;
        // console.log(leavelist.list);
    })
  }
  // 查看请假审核列表
  function leaveReview_Check(row){
    // console.log(leavelist._rawValue);
    leave_review_check({id:row}).then((res)=>{
      // console.log(res.data.list);
      checksreviewlist.value.list = res.data.list;
      // console.log(checksreviewlist.value.list);
      // console.log(res.data.obj);
    })
  }

  // 获取健康中心列表
  function health_List() {
    health_list().then((res)=>{
        // console.log(res.data.list);
        healthlist.value.list = res.data.list;
        // console.log(leavelist.value.list);
    })
  }
  // 撤销健康中心列表
  function healthList_delete(row){
    // console.log(leavelist._rawValue);
    health_delete({id:row}).then((res)=>{
      healthlist.value.list = res.data.list;
      // console.log(leavelist.value);
      // console.log(res.data.list);
    })
  }
  // 添加提醒健康中心列表
  function healthList_remind(row){
    health_remind(row).then((res)=>{
     if(res.status == 200){
      healthlist.value = res.data.list
     }
    })
  }
  return { leavelist,leavelistcheck,healthlist,checkslist,checksreviewlist,leave_List,leaveList_delete,leaveList_check,leaveList_add,health_List,healthList_delete,healthList_remind,leaveReview_List,leaveReview_Check}
})